package com.jack006.stock.task;

import com.jack006.stock.service.StockService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;

/**
 * @Classname TaskRecordNowDetail
 * @Description 记录股票详情实时
 * @Date 2021-07-09 21:52
 * @Created by jack
 */
@Configuration
@EnableScheduling
public class TaskRecordNowDetail {

    final static Logger logger = LoggerFactory.getLogger(TaskRecordNowDetail.class);


    @Autowired
    private StockService stockService;

    /**
     * 添加定时任务
     */
    @Scheduled(cron = "0/15 * 9,10,13,14 * * ?")
    private void  recordFlushInfo(){
        logger.info("开始执行每日实时数据采集任务:"+ LocalDateTime.now());

        // 调用文章 Service,把当前时间应该发布的定时文章
        stockService.recordStockNowDetail();

        logger.info("完成执行每日定时实时数据采集任务:");
    }


    /**
     * 添加定时任务
     */
    @Scheduled(cron = "0 10 15 * * ?")
    private void recordDayInfo(){
        logger.info("开始执行每日统计数据采集任务:"+ LocalDateTime.now());

        // 调用文章 Service,把当前时间应该发布的定时文章
        stockService.recordStockDayDetail();

        logger.info("完成执行每日统计数据采集任务:");
    }
}
